{extend name="common/main"/}

{block name="body"}
    <div class="main-title">
        <h2>扩展配置管理</h2>
    </div>

    <div class="row clearfix button-box">
        <div class="col-xs-10">
            <a class="btn btn-info" href="{:url('edit')}">新增</a>
            <a class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids" >删除</a>
            <!-- 高级搜索 -->
        </div>
        <div class="col-xs-2">
            <div class="search-form">
                <div class="sleft">
                    <div class="input-group">
                        <input type="text" name="name" class="form-control" value="{:input('name')}" placeholder="请输入配置名称">
                        <span class="input-group-btn">
                            <a class="btn btn-default" href="javascript:;" id="search" url="{:url('config/list')}">
                                <i class="icon-search"></i>
                            </a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="with-padding">
        <table class="table table-bordered table-striped muu-table">
            <thead>
            <tr>
            <tr>
                <th class="row-selected">
                    <input class="checkbox check-all" id="check-all" type="checkbox">
                    <label for="check-all"></label>
                </th>
                <th>{:lang('ID')}</th>
                <th>唯一标识</th>
                <th>标题</th>
                <th>分组</th>
                <th>类型</th>
                <th>操作</th>
            </tr>
            </tr>
            </thead>
            <tbody>
            {notempty name="list"}
            {volist name="list" id="config"}
                <tr>
                    <td>
                        <input class="ids row-selected" id="ids-{$config.id}" type="checkbox" name="id[]" value="{$config.id}">
                        <label for="ids-{$config.id}"></label>
                    </td>
                    <td>{$config.id}</td>
                    <td>{$config.name}</td>
                    <td>{$config.title}</td>
                    <td>{$config.group|get_extend_group}</td>
                    <td>{$config.type|get_config_type}</td>
                    <td>
                        <a title="{:lang('_EDIT_')}" href="{:url('edit?id='.$config['id'])}">编辑</a>
                        <a class="confirm ajax-get" title="{:lang('_DELETE_')}" href="{:url('del?id='.$config['id'])}">删除</a>
                    </td>
                </tr>
            {/volist}
            {else/}
                <td colspan="7" class="text-center"> 空空如也~</td>
            {/notempty}
            </tbody>
        </table>
        <div class="">
            {:htmlspecialchars_decode($page)}
        </div>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function (e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
        });
    </script>
{/block}